<div class="task-contents-container">
  <div class="title">
    <%= t("projects.reports.wizard.third_step.title") %>
  </div>
  <div class="select-all-container">
    <span class="sci-checkbox-container">
      <input type="checkbox" class="sci-checkbox select-all-task-contents"/>
      <span class="sci-checkbox-label"></span>
    </span>
    <%= t("projects.reports.wizard.third_step.select_all") %>
  </div>
  <div class="divider"></div>
  <ul class="report-task-settings">
    <li class="content-element">
      <i class="sn-icon sn-icon-down " data-toggle="collapse" href="#protocolContents" aria-expanded="false"></i>
      <span class="content-element-title">
        <%= t("projects.reports.wizard.third_step.task_protocol") %>
      </span>
      <ul class="protocol-contents collapse in" id="protocolContents">
        <li>
          <span class="sci-checkbox-container">
            <input type="checkbox" class="sci-checkbox protocol-setting" value="description" <%= 'checked' if report.settings.dig(:task, :protocol, :description) %>/>
            <span class="sci-checkbox-label"></span>
          </span>
          <%= t("projects.reports.wizard.third_step.protocol_description") %>
          <div class="divider"></div>
        </li>
        <li>
          <span class="sci-checkbox-container">
            <input type="checkbox" class="sci-checkbox protocol-steps-checkbox" value="protocol_steps"/>
            <span class="sci-checkbox-label"></span>
          </span>
          <%= t("projects.reports.wizard.third_step.protocol_step") %>
          <div class="divider"></div>
          <ul class="step-contents report-protocol-settings">
            <% %i(completed_steps uncompleted_steps step_texts step_files step_tables step_well_plates step_checklists step_comments).each do |step_content| %>
              <li>
                <span class="sci-checkbox-container">
                  <input type="checkbox" class="sci-checkbox protocol-setting" value="<%= step_content %>" <%= 'checked' if report.settings.dig(:task, :protocol, step_content) %> />
                  <span class="sci-checkbox-label"></span>
                </span>
                <%= t("projects.reports.wizard.third_step.#{step_content}") %>
                <div class="divider"></div>
              </li>
            <% end %>
          </ul>
        </li>
      </ul>
    </li>
    <div class="divider"></div>
    <li class="content-element">
      <i class="sn-icon sn-icon-down " data-toggle="collapse" href="#repositoriesContents" aria-expanded="false"></i>
      <span class="content-element-title">
        <%= t("projects.reports.wizard.third_step.assigned_items") %>
      </span><br>
      <span class="repositories-items-description">
        <i class="sn-icon sn-icon-info"></i>
        <div class="flex-col font-normal">
          <p><%= t("projects.reports.wizard.third_step.assigned_items_description") %></p>
          <p><%= t("projects.reports.wizard.third_step.assigned_items_repository_items_description_html") %></p>
        </div>
      </span>
      <ul class="collapse in" id="repositoriesContents">
        <li>
          <span class="sci-checkbox-container">
            <input type="checkbox" class="sci-checkbox select-all-repositories"/>
            <span class="sci-checkbox-label"></span>
          </span>
          <%= t("projects.reports.wizard.third_step.include_all_assigned_iitems") %>
          <div class="divider"></div>
          <ul class="repositories-contents">
            <% @repositories.each do |repository| %>
              <li>
                 <div class="flex items-center">
                  <span class="sci-checkbox-container">
                    <input type="checkbox"
                          class="sci-checkbox repositories-setting"
                          value="<%= repository.is_a?(RepositorySnapshot) ? repository.parent_id : repository.id %>"
                          <%= 'checked' if report.new_record? ||
                                            @project_contents[:repositories].include?(repository.id) ||
                                            (repository.is_a?(Repository) && repository.repository_snapshots.exists?(id: @project_contents[:repositories])) ||
                                            (repository.is_a?(RepositorySnapshot) && @project_contents[:repositories].include?(repository.parent_id)) %> />
                    <span class="sci-checkbox-label"></span>
                  </span>
                  <%= repository.name %>
                  <% if repository.archived? %>
                    <span class="archived">
                      <%= t("projects.reports.wizard.third_step.archived") %>
                    </span>
                  <% elsif repository.is_a?(RepositorySnapshot) %>
                    <span class="deleted">
                      <%= t("projects.reports.wizard.third_step.deleted") %>
                    </span>
                  <% end %>
                  <select class="repository-columns"
                          id=<%= "repository-#{repository.id}" %>
                          data-combine-tags="true"
                          data-placeholder="<%= t("projects.reports.wizard.third_step.repository_column.placeholder") %>"
                          data-select-multiple-all-selected="<%= t("projects.reports.wizard.third_step.repository_column.all_selected") %>"
                          data-select-multiple-name="<%= t("projects.reports.wizard.third_step.repository_column.selected") %>"
                          data-select-all-button="<%= t("projects.reports.wizard.third_step.repository_column.select_deselect_all") %>"
                          multiple
                  >
                   <% Report.default_repository_columns.each do |key, value| %>
                      <option value="<%= key %>"
                              selected-value="<%= report.settings.dig(:task, 
                                                                      :excluded_repository_columns,
                                                                      (repository.is_a?(RepositorySnapshot) ? repository.parent_id : repository.id).to_s)
                                                                 &.include?(key.to_s.to_i) ? '' : 'selected' %>"
                      >
                        <%= value %>
                      </option>
                    <% end %>
                    <% repository.repository_columns.find_each do |repository_column| %>
                      <option value="<%= repository_column.id %>"
                              selected-value="<%= report.settings.dig(:task,
                                                                      :excluded_repository_columns,
                                                                      (repository.is_a?(RepositorySnapshot) ? repository.parent_id : repository.id).to_s)
                                                                 &.include?(repository_column.id.to_i) ? '' : 'selected' %>"
                      >
                        <%= repository_column.name %>
                      </option>
                    <% end %>
                  </select>
                </div>
                <div class="divider"></div>
              </li>
            <% end %>
          </ul>
        </li>
      </ul>
    </li>
    <div class="divider"></div>
    <li class="content-element">
      <i class="sn-icon sn-icon-down " data-toggle="collapse" href="#resultContents" aria-expanded="false"></i>
      <span class="content-element-title">
        <%= t("projects.reports.wizard.third_step.results") %>
      </span>
      <ul class="result-contents collapse in" id="resultContents">
        <li>
          <div class="all-results-container">
            <span class="sci-checkbox-container">
              <input type="checkbox" class="sci-checkbox all-results-checkbox" value="all_results"/>
              <span class="sci-checkbox-label"></span>
            </span>
            <span>
              <%= t("projects.reports.wizard.third_step.all_results") %>
              <div class="results-order-contaner">
                <label>
                  <%= t("projects.reports.wizard.third_step.order_results") %>
                </label>
                <%= select_tag :taskResultsOrder,
                               options_for_select([
                                 [t('projects.reports.wizard.third_step.atoz'), 'atoz'],
                                 [t('projects.reports.wizard.third_step.ztoa'), 'ztoa'],
                                 [t('projects.reports.wizard.third_step.old'), 'old'],
                                 [t('projects.reports.wizard.third_step.new'), 'new'],
                                 [t('projects.reports.wizard.third_step.old_updated'), 'old_updated'],
                                 [t('projects.reports.wizard.third_step.new_updated'), 'new_updated']
                               ], selected: report.settings.dig(:task, :result_order)),
                               class: 'order-results' %>
              </div>
            </span>
          </div>
          <div class="divider"></div>
          <ul class="results-type-contents report-result-settings">
            <li>
              <span class="sci-checkbox-container">
                <input type="checkbox" class="sci-checkbox task-setting" value="text_results" <%= 'checked' if report.settings.dig(:task, :text_results) %>/>
                <span class="sci-checkbox-label"></span>
              </span>
              <%= t("projects.reports.wizard.third_step.text_results") %>
              <div class="divider"></div>
            </li>
            <li>
              <div class="file-result-title-container">
                <span class="sci-checkbox-container">
                  <input type="checkbox" class="sci-checkbox task-setting" value="file_results" <%= 'checked' if report.settings.dig(:task, :file_results) %>/>
                  <span class="sci-checkbox-label"></span>
                </span>
                <span>
                  <%= t("projects.reports.wizard.third_step.file_results") %>
                  <div class="include-pages-container">
                    <span class="sci-checkbox-container">
                      <input type="checkbox" class="sci-checkbox task-setting skip-select-all" value="file_results_previews" <%= 'checked' if report.settings.dig(:task, :file_results_previews) %>/>
                      <span class="sci-checkbox-label"></span>
                    </span>
                    <%= t("projects.reports.wizard.third_step.insert_pages_from_pdf") %><br>
                    <i class="fas fa-exclamation-triangle"></i>
                    <%= t("projects.reports.wizard.third_step.pdf_warning") %>
                  </div>
                </span>
              </div>
              <div class="divider"></div>
            </li>
            <li>
              <span class="sci-checkbox-container">
                <input type="checkbox" class="sci-checkbox task-setting " value="table_results" <%= 'checked' if report.settings.dig(:task, :table_results) %>/>
                <span class="sci-checkbox-label"></span>
              </span>
              <%= t("projects.reports.wizard.third_step.table_results") %>
              <div class="divider"></div>
            </li>
            <li>
              <span class="sci-checkbox-container">
                <input type="checkbox" class="sci-checkbox task-setting" value="result_comments" <%= 'checked' if report.settings.dig(:task, :result_comments) %>/>
                <span class="sci-checkbox-label"></span>
              </span>
              <%= t("projects.reports.wizard.third_step.results_comments") %>
              <div class="divider"></div>
            </li>
          </ul>
        </li>
      </ul>
      <div class="divider"></div>
    </li>
    <li class="content-element">
      <i class="sn-icon sn-icon-down " data-toggle="collapse" href="#additionalContents" aria-expanded="false"></i>
      <span class="content-element-title">
        <%= t("projects.reports.wizard.third_step.additional_content") %>
      </span>
      <ul class="additional-contents collapse in" id="additionalContents">
        <li class="additional-content-task-activity">
          <div class="select-all-container">
            <span class="sci-checkbox-container">
              <input type="checkbox" class="sci-checkbox task-setting" value="activities" <%= 'checked' if report.settings.dig(:task, :activities) %>/>
              <span class="sci-checkbox-label"></span>
            </span>
            <%= t("projects.reports.wizard.third_step.task_activity") %>
            <div class="divider"></div>
          </div>
        </li>
        <li>
          <div class="select-all-container">
            <span class="sci-checkbox-container">
              <input type="checkbox" class="sci-checkbox exclude-task-metadata-setting" value="exclude_task_metadata" <%= 'checked' if report.settings.dig(:exclude_task_metadata) %>/>
              <span class="sci-checkbox-label"></span>
            </span>
            <%= t("projects.reports.wizard.third_step.exclude_task_metadata") %>
            <div class="divider"></div>
          </div>
        </li>
        <li>
          <div class="select-all-container">
            <span class="sci-checkbox-container">
              <input type="checkbox" class="sci-checkbox exclude-timestamps-setting" value="exclude_timestamps" <%= 'checked' if report.settings.dig(:exclude_timestamps) %>/>
              <span class="sci-checkbox-label"></span>
            </span>
            <%= t("projects.reports.wizard.third_step.exclude_timestamps") %>
            <div class="divider"></div>
          </div>
        </li>
      </ul>
  </ul>
</div>
